//
//  BH_UnderLineButton.m
//  Coin
//
//  Created by yangy on 2018/6/25.
//  Copyright © 2018年 zzg. All rights reserved.
//

#import "BH_UnderLineButton.h"

@implementation BH_UnderLineButton

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if(self){
        self.lineHeight = 1;
    }
    return self;
}

- (void)setLineColor:(UIColor *)lineColor
{
    _lineColor = lineColor;
    [self setNeedsDisplay];
}

- (void)drawRect:(CGRect)rect
{
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetFillColorWithColor(context, self.lineColor.CGColor);
    CGContextFillRect(context, CGRectMake(0, CGRectGetHeight(self.frame)-self.lineHeight, CGRectGetWidth(self.frame), self.lineHeight));
}
- (void)setTitleColor:(UIColor *)color forState:(UIControlState)state
{
    [super setTitleColor:color forState:state];
    self.lineColor = color;
    [self setNeedsDisplay];
}

@end
